package com.etone.smartAudit.controller;

import com.etone.smartAudit.service.ServerSourceService;
import com.etone.smartAudit.vo.PagerVO;
import com.etone.smartAudit.vo.serverSource.ServerSourceSimpleVO;
import com.etone.smartAudit.vo.serverSource.ServerSourceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: sovy
 * @date: 2020/10/28
 * @description:
 */
@AllArgsConstructor
@RestController
@Api(tags = "服务器资源管理", value = "ServerSourceController")
public class ServerSourceController {
    private ServerSourceService serverSourceService;

    @ApiOperation(value = "服务器软件资源信息列表《完》")
    @GetMapping("/serverSources")
    public PagerVO<ServerSourceVO> list(
            @ApiParam(value = "服务器id") @RequestParam(required = false) Integer serverInfoId,
            @ApiParam(value = "当前页") @RequestParam(required = false, defaultValue = "1") int page,
            @ApiParam(value = "每页显示数量") @RequestParam(required = false, defaultValue = "10") int pageSize
    ) {
        return serverSourceService.list(serverInfoId, page, pageSize);
    }

    @ApiOperation(value = "服务器软件资源基本信息列表《完》")
    @GetMapping("/serverSources/simple")
    public PagerVO<ServerSourceSimpleVO> listSimple(
            @ApiParam(value = "当前页") @RequestParam(required = false, defaultValue = "1") int page,
            @ApiParam(value = "每页显示数量") @RequestParam(required = false, defaultValue = "10") int pageSize
    ) {
        return serverSourceService.listSimple(page, pageSize);
    }

    @ApiOperation(value = "服务器软件资源信息详情《完》")
    @GetMapping("/serverSources/{id}")
    public ServerSourceVO detail(
            @ApiParam(value = "id", required = true) @PathVariable Integer id
    ) {
        return serverSourceService.detail(id);
    }

}
